<span page-title ng-model="host">{{ 'Content Host' | translate }} {{ host.name }}</span>

<div ng-hide="host.hasSubscription()">
  <div data-extend-template="common/views/registration.html"></div>
</div>

<div ng-show="host.hasSubscription()">
  <div data-extend-template="layouts/two-column-details.html">
    <div data-block="left-column">
      <h4 translate>Basic Information</h4>

      <dl class="dl-horizontal dl-horizontal-left">
        <dt translate>Name</dt>
        <dd bst-edit-text="host.name"
            readonly="denied('edit_hosts', host)"
            on-save="save(host)">
        </dd>

        <dt translate>Subscription UUID</dt>
        <dd>{{ host.subscription_facet_attributes.uuid }}</dd>

        <dt translate>BIOS UUID</dt>
        <dd>{{ host.subscription_facet_attributes.dmi_uuid }}</dd>

        <dt translate>Description</dt>
        <dd bst-edit-textarea="host.comment"
            readonly="denied('edit_hosts', host)"
            on-save="save(host)">
        </dd>

        <dt translate>Type</dt>
        <dd>{{ host.subscription_facet_attributes.host_type }}</dd>

        <dt>
          <span translate>Katello Tracer</span>
          <span>
            <i class="pficon-info" title="{{ 'Tracer helps administrators identify applications that need to be restarted after a system is patched.' | translate }}"></i>
          </span>
        </dt>
        <dd>
          <span ng-show="host.content_facet_attributes.katello_tracer_installed">
            <span class="{{ getHostStatusIcon(0) }}"></span>
            <span translate>Installed</span>
          </span>
          <button
            class="btn btn-default"
            type="button"
            ng-hide="denied('edit_hosts', host) || host.content_facet_attributes.katello_tracer_installed"
            ng-click="installTracerPackage(host)">
            <span translate>Enable Traces</span>
          </button>
        </dd>

        <dt bst-feature-flag="remote_actions" ng-show="katelloAgentPresent">
          <span translate>Katello Agent</span>
        </dt>
        <dd bst-feature-flag="remote_actions" ng-show="katelloAgentPresent">
          <span ng-show="host.content_facet_attributes.katello_agent_installed">
            <span class="{{ getHostStatusIcon(0) }}"></span>
            <span translate>Installed</span>
          </span>
          <span ng-hide="host.content_facet_attributes.katello_agent_installed">
            <span class="{{ getHostStatusIcon(1) }}"></span>
            <span translate>Not installed</span>
          </span>
        </dd>

        <dt ng-show="host.subscription_facet_attributes.virtual_guests" translate>Virtual Guests</dt>
        <dd ng-show="host.subscription_facet_attributes.virtual_guests">
          <a ng-href="/content_hosts?search={{virtualGuestIds(host)}}"
             translate translate-n="host.subscription_facet_attributes.virtual_guests.length"
             translate-plural="{{ host.subscription_facet_attributes.virtual_guests.length }} Content Hosts">
            1 Content Host
          </a>
        </dd>

        <dt ng-show="!host.subscription_facet_attributes.hypervisor || host.subscription_facet_attributes.registered_through" translate>Registered Through</dt>
        <dd ng-show="!host.subscription_facet_attributes.hypervisor || host.subscription_facet_attributes.registered_through">{{ host.subscription_facet_attributes.registered_through | translate}}</dd>

        <dt ng-show="host.subscription_facet_attributes.virtual_host" translate>Virtual Host</dt>
        <dd ng-show="host.subscription_facet_attributes.virtual_host">
          <a ui-sref="content-host.info({hostId: host.subscription_facet_attributes.virtual_host.id })">{{ host.subscription_facet_attributes.virtual_host.name }}</a>
        </dd>
      </dl>

      <div class="divider"></div>

      <h4 translate>Subscriptions</h4>

      <dl class="dl-horizontal dl-horizontal-left">
        <dt translate>Subscription Status</dt>
        <dd>
          <i ng-class="getHostStatusIcon(host.subscription_global_status)"></i>
          {{ host.subscription_status_label }}
        </dd>

        <dt translate ng-if="!simpleContentAccessEnabled">Details</dt>
        <dd ng-if="!simpleContentAccessEnabled">
          <ul class="compliance-reasons">
            <li ng-repeat="reason in host.subscription_facet_attributes.compliance_reasons">{{ reason }}</li>
          </ul>
        </dd>

        <dt translate ng-if="!simpleContentAccessEnabled">Auto-Attach Details</dt>
        <dd ng-if="!simpleContentAccessEnabled"
            bst-edit-select="host.subscription_facet_attributes.autoheal"
            selector="host.subscription_facet_attributes.autoheal"
            options="autoHealOptions()"
            readonly="denied('edit_hosts', host)"
            formatter="booleanToYesNo"
            on-save="saveSubscriptionFacet(host)">
        </dd>
      </dl>

      <div class="divider"></div>

      <div style="display: inline-block"><h4 translate>System Purpose</h4></div>
      <div style="display: inline-block"><i class="pficon-info" title="{{ 'System Purpose allows you to set the system\'s intended use on your network and improves the accuracy of auto attaching subscriptions.' | translate }}"></i></div>

      <dl class="dl-horizontal dl-horizontal-left">
        <dt translate ng-hide="simpleContentAccessEnabled">System Purpose Status</dt>
        <dd ng-hide="simpleContentAccessEnabled">
          <i ng-class="getHostPurposeStatusIcon(host.purpose_status)"></i>
          {{ host.purpose_status_label }}
        </dd>
        <dt translate>Service Level (SLA)</dt>
        <dd bst-edit-select="host.subscription_facet_attributes.service_level"
            readonly="denied('edit_hosts', host)"
            icon-class="getHostPurposeStatusIcon(host.purpose_sla_status)"
            icon-show="host.purpose_sla_status > 0"
            selector="host.subscription_facet_attributes.service_level"
            options="serviceLevels()"
            options-format="option for option in options"
            deletable="true"
            on-delete="clearServiceLevel()"
            on-save="saveSubscriptionFacet(host)">
        </dd>

        <dt translate>Usage Type</dt>
        <dd bst-edit-select="host.subscription_facet_attributes.purpose_usage"
            readonly="denied('edit_hosts', host)"
            icon-class="getHostPurposeStatusIcon(host.purpose_usage_status)"
            icon-show="host.purpose_usage_status > 0"
            selector="host.subscription_facet_attributes.purpose_usage"
            options="purposeUsages()"
            options-format="option for option in options"
            deletable="true"
            on-delete="clearUsage()"
            on-save="saveSubscriptionFacet(host)">
        </dd>

        <dt translate>Role</dt>
        <dd bst-edit-select="host.subscription_facet_attributes.purpose_role"
            readonly="denied('edit_hosts', host)"
            icon-class="getHostPurposeStatusIcon(host.purpose_role_status)"
            icon-show="host.purpose_role_status > 0"
            selector="host.subscription_facet_attributes.purpose_role"
            options="purposeRoles()"
            options-format="option for option in options"
            deletable="true"
            on-delete="clearRole()"
            on-save="saveSubscriptionFacet(host)">
        </dd>

        <dt translate>Add ons</dt>
        <dd bst-edit-multiselect="host.subscription_facet_attributes.purpose_addons"
            readonly="denied('edit_hosts', host) || purposeAddonsCount === 0"
            icon-class="getHostPurposeStatusIcon(host.purpose_addons_status)"
            icon-show="host.purpose_addons_status > 0"
            formatter="arrayToString"
            deletable="true"
            on-delete="clearAddOns()"
            selector="host.subscription_facet_attributes.purpose_addons"
            options="purposeAddons()"
            on-save="saveSubscriptionFacet(host)">
        </dd>

      </dl>

      <div class="divider"></div>

      <h4 translate>Content Host Properties</h4>

      <dl class="dl-horizontal dl-hoizontal-left">
        <dt translate>OS</dt>
        <dd>{{ host.operatingsystem_name }}</dd>

        <dt translate>Architecture</dt>
        <dd>{{ host.architecture_name }}</dd>

        <dt translate>Number of CPUs</dt>
        <dd>{{ host.facts["cpu::cpu(s)"] }}</dd>

        <dt translate>Sockets</dt>
        <dd>{{ host.facts['cpu::cpu_socket(s)'] }}</dd>

        <dt translate>Cores per Socket</dt>
        <dd>{{ host.facts['cpu::core(s)_per_socket'] }}</dd>

        <dt translate>RAM (GB)</dt>
        <dd>{{ hostRam(host) }}</dd>

        <dt translate>Virtual Guest</dt>
        <dd>{{ virtual(host.facts['virt::is_guest']) | booleanToYesNo }}</dd>
      </dl>

      <div class="divider"></div>

      <h4 translate>Installed Products</h4>

      <p translate ng-show="!host.subscription_facet_attributes.installed_products || host.subscription_facet_attributes.installed_products.length == 0">
        You do not have any Installed Products
      </p>

      <div ng-show="host.subscription_facet_attributes.installed_products.length > 0">
        <div ng-repeat="product in host.subscription_facet_attributes.installed_products" class="detail">
          <dt translate>Product</dt>
          <dd>{{ product.productName }} {{ product.version }}</dd>
        </div>
      </div>
    </div>

    <div data-block="right-column">
      <h4 translate>Installable Errata</h4>

      <dl class="dl-horizontal dl-horizontal-left">
        <dt translate>Security</dt>
        <dd>
          <a ui-sref="content-host.errata.index({getSearch: 'type=security'})" ng-class="{black: !host.content_facet_attributes.errata_counts.security, red: host.content_facet_attributes.errata_counts.security > 0}">
            <i class="fa fa-warning inline-icon" title="{{ 'Security' | translate }}"></i>
            {{ host.content_facet_attributes.errata_counts.security || 0 }}
          </a>
        </dd>

        <dt translate>Bug Fix</dt>
        <dd>
          <a ui-sref="content-host.errata.index({getSearch: 'type=bugfix or type=recommended'})" ng-class="{black: !host.content_facet_attributes.errata_counts.bugfix, yellow: host.content_facet_attributes.errata_counts.bugfix > 0}">
            <i class="fa fa-bug inline-icon" title="{{ 'Bug Fix' | translate }}"></i>
            {{ host.content_facet_attributes.errata_counts.bugfix || 0 }}
          </a>
        </dd>

        <dt translate>Enhancement</dt>
        <dd>
          <a ui-sref="content-host.errata.index({getSearch: 'type=enhancement or type=optional'})" ng-class="{black: !host.content_facet_attributes.errata_counts.enhancement, yellow: host.content_facet_attributes.errata_counts.enhancement > 0}">
            <i class="fa fa-plus-square inline-icon" title="{{ 'Enhancement' | translate }}"></i>
            {{ host.content_facet_attributes.errata_counts.enhancement || 0 }}
          </a>
        </dd>
      </dl>

      <div class="divider"></div>

      <h4 translate>Content Host Content</h4>
      <dl class="dl-horizontal dl-horizontal-left">
        <dt translate>Release Version</dt>
        <dd>
          <div bst-edit-select="host.subscription_facet_attributes.release_version"
              readonly="denied('edit_hosts', host)"
              selector="host.subscription_facet_attributes.release_version"
              options="releaseVersions()"
              options-format="option for option in options"
              deletable="true"
              on-delete="clearReleaseVersion()"
              on-save="saveSubscriptionFacet(host)"
              on-cancel="cancelReleaseVersionUpdate()">
          </div>
          <div bst-alert="info" ng-show="showVersionAlert">
            <p translate>
              No alternate release version choices are available. The available releases are based upon what is available in "{{ host.content_facet_attributes.content_view.name }}", the selected <a href="/content_views">content view</a> this content host is attached to for the given <a href="/lifecycle_environments">lifecycle environment</a>, "{{ host.content_facet_attributes.lifecycle_environment.name }}".
            </p>
          </div>
        </dd>

        <dt translate>Content View</dt>
        <dd>
          <div bst-edit-select="host.content_facet_attributes.content_view.name"
            readonly="denied('edit_hosts', host)"
            selector="host.content_facet_attributes.content_view.id"
            options="availableContentViews()"
            on-cancel="cancelContentViewUpdate()"
            on-save="saveContentView(host)"
            edit-trigger="editContentView">
            </div>
            <div class="help-block" ng-show="showCVAlert">
              <p translate>
                Changing the Content View will not affect the Content Host until its next checkin.
                To update the Content Host immediately run the following command:
              </p>
              <code># subscription-manager refresh</code>
            </div>
        </dd>

        <dt bst-feature-flag="lifecycle_environments">
          <span translate>Lifecycle Environment</span>
        </dt>
        <dd bst-feature-flag="lifecycle_environments">
          <div bst-alert="info" ng-show="editContentView">
            <p translate ng-show="contentViews.length === 0">
              The host requires being attached to a content view and the lifecycle environment you have chosen has no content views promoted to it.
              See the <a href="/content_views">content views page</a> to manage and promote a content view.
            </p>
            <p translate ng-show="contentViews.length !== 0">
              You must select a new content view before your change of lifecycle environment can be saved.
            </p>
            <p translate>
              Use the cancel button on content view selection to revert your lifecycle environment selection.
            </p>
          </div>

          <span path-selector="environments"
                ng-model="host.content_facet_attributes.lifecycle_environment"
                mode="singleSelect"
                disabled="denied('edit_hosts', host)"
                disable-trigger="disableEnvironmentSelection">
          </span>
        </dd>
      </dl>

      <div class="divider"></div>

      <h4 translate>Content Host Status</h4>

      <dl class="dl-horizontal dl-horizontal-left">
        <dt translate>Registered</dt>
        <dd><long-date-time date="host.created_at" /></dd>

        <dt translate> Registered By</dt>
        <dd>
            <span ng-show="host.subscription_facet_attributes.activation_keys.length == 0" translate>
              {{ host.subscription_facet_attributes.user.login }}
            </span>
            <span ng-show="host.subscription_facet_attributes.activation_keys.length > 0"
                  translate
                  translate-n="host.subscription_facet_attributes.activation_keys.length"
                  translate-plural="Activation Keys">
              Activation Key
            </span>

          <ul ng-show="host.subscription_facet_attributes.activation_keys.length > 0">
            <li ng-repeat="activation_key in host.subscription_facet_attributes.activation_keys">
                <span>
                  <a ui-sref="activation-key.info({activationKeyId: activation_key.id})">
                    {{ activation_key.name }}
                  </a>
                </span>
              <span ng-show="activation_key.description"> - {{ activation_key.description }}</span>
            </li>
          </ul>
        </dd>

        <dt translate>Last Checkin</dt>
        <dd><long-date-time date="host.subscription_facet_attributes.last_checkin" default="'Never checked in' | translate" /></dd>
      </dl>

      <div class="divider"></div>

      <h4 translate>Networking</h4>

      <dl class="dl-horizontal dl-horizontal-left">
        <dt translate>Hostname</dt>
        <dd>{{ host.name }}</dd>

        <dt translate>IPv4 Address</dt>
        <dd>{{ host.facts["network::ipv4_address"] }}</dd>

        <dt translate>IPv6 Address</dt>
        <dd>{{ host.facts["network::ipv6_address"] }}</dd>

        <dt translate>Interfaces</dt>
        <dd>
          <div ng-repeat="(interfaceName, interface) in hostFactsAsObject.net.interface" >
            <i ng-class="{'fa fa-plus': !expanded, 'fa fa-minus': expanded}" class="expand-icon"
               ng-hide="editMode" ng-click="expanded = !expanded"></i>
            {{ interfaceName }}
            <div class="sub-detail" ng-show="expanded">
              <div ng-repeat="(key, value) in interface">
                <span class="info-sub-label">{{ key.replace("_", " ") }}:</span>
                <span class="info-sub-value">{{ value }}</span>
              </div>
            </div>
          </div>
        </dd>
      </dl>
    </div>
  </div>
</div>
